package GUI;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Amount extends JPanel implements KeyListener {
	private Controller control;
	private JTextField amount;
	public Amount(Controller c)
	{
		this.control = c;
		amount = new JTextField(control.getfieldLength());
		amount.addKeyListener(this);
		
		JLabel amountLabel = new JLabel("Amount: ");
		JPanel panel = new JPanel(new FlowLayout(1,0,-1));
		JPanel textPanel = new JPanel();
		JPanel fieldPanel = new JPanel();
		textPanel.add(amountLabel);
		fieldPanel.add(amount);
		panel.add(textPanel);
		panel.add(fieldPanel);
		add(panel, BorderLayout.LINE_START);
	}

	@Override
	public void keyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		control.setAmount(this.amount.getText());
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		control.setAmount(this.amount.getText());
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		control.setAmount(this.amount.getText());
	}
}
